import time

import utime
from machine import PWM, Pin

ledPin = PWM(Pin(2))

ledPin.freq(50)

while True:
    time1 = utime.ticks_us()
    for i in range(1, 65536):
        ledPin.duty_u16(i)
        # time.sleep(0.00001)
        # print(i)
    time2 = utime.ticks_us()
    print("变亮共花费\t", (time2 - time1) / 1000000, "\t秒")
    for i in range(65535, 0, -1):
        ledPin.duty_u16(i)
        # time.sleep(0.00001)
        # print(i)
    time3 = utime.ticks_us()
    print("变暗共花费\t", (time3 - time2) / 1000000, "\t秒")
    print("一共花费\t", (time3 - time1) / 1000000, "\t秒")
    print("***********************************************************")
